-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example of post-processor to have integer CPU #63
Conversation
e3d2622
to
12ee968
Compare
@@ -57,6 +57,9 @@ var ( | |||
ctrPodNameLabel = flag.String("container-pod-name-label", "pod_name", `Label name to look for container pod names`) | |||
ctrNameLabel = flag.String("container-name-label", "name", `Label name to look for container names`) | |||
vpaObjectNamespace = flag.String("vpa-object-namespace", apiv1.NamespaceAll, "Namespace to search for VPA objects and pod stats. Empty means all namespaces will be used.") | |||
|
|||
// recommendation post processor flags | |||
postProcessorCPUasInteger = flag.Bool("recommendation-post-processor-cpu-as-integer-enabled", false, `Enable recommendation post process to have CPU as integer if requested by user in VPA object`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a list of pre processors instead
// vpa-post-processor.kubernetes.io/{containerName}_integerCPU=true | ||
|
||
vpaPostProcessorPrefix = "vpa-post-processor.kubernetes.io/" | ||
vpaPostProcessorIntegerCPUSuffix = "_integerCPU" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be -integer-cpu
?
apiv1 "k8s.io/api/core/v1" | ||
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" | ||
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model" | ||
"math" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import ordering seems wrong
if resourceName != apiv1.ResourceCPU { | ||
continue | ||
} | ||
v := float64(recommended.MilliValue()) / 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1000.
?
|
||
// extractContainerName return the container name for the feature based on annotation key | ||
// if the return value is empty that means that the key does not match | ||
func extractContainerName(key, prefix, suffix string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely to be re-used and should be in a shared module no ?
52c0e1a
to
e608038
Compare
Merged upstream |
Which component this PR applies to?
vertical-pod-autoscaler/recommender
What type of PR is this?
/kind feature
What this PR does / why we need it:
It introduces a recommendation post processor that allows users to have a CPU integer as recommendation.
Thanks to that it is now possible to VPA for application using static CPU allocation
Which issue(s) this PR fixes:
Fixes kubernetes#5236
Special notes for your reviewer:
This PR is an example about how to use kubernetes#5239
Does this PR introduce a user-facing change?
It does not break any existing API.
With this implementation users activate the feature by adding an annotation their VPA objects:
vpa-post-processor.kubernetes.io/{containerName}_integerCPU=true
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
This post processor is optional. To run it in the recommender the command-line flag should be set:
--recommendation-post-processors="integerCPU,capping"